home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 18 April 1997
- //
- // Description:
- // sine default options box. The content for each tab
- // is not created until it is accessed for the first time.
- //
- //////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- // min.
- //
- if ($forceFactorySettings || !`optionVar -exists sineMin`) {
- optionVar -floatValue sineMin -1.0;
- }
-
- // max.
- //
- if ($forceFactorySettings || !`optionVar -exists sineMax`) {
- optionVar -floatValue sineMax 1.0;
- }
-
- // amplitude.
- //
- if ($forceFactorySettings || !`optionVar -exists sineAmplitude`) {
- optionVar -floatValue sineAmplitude 0.0;
- }
-
- // wavelength.
- //
- if ($forceFactorySettings || !`optionVar -exists sineWavelength`) {
- optionVar -floatValue sineWavelength 2.0;
- }
-
- // dropoff.
- //
- if ($forceFactorySettings || !`optionVar -exists sineDropoff`) {
- optionVar -floatValue sineDropoff 0.0;
- }
-
- // offset.
- //
- if ($forceFactorySettings || !`optionVar -exists sineOffset`) {
- optionVar -floatValue sineOffset 0.0;
- }
- // default options common to all deformers
- //
- if ($forceFactorySettings || !`optionVar -exists sinePositioning`) {
- optionVar -stringValue sinePositioning "default";
- }
- if ($forceFactorySettings || !`optionVar -exists sineExclusive`) {
- optionVar -intValue sineExclusive 0;
- }
- if ($forceFactorySettings || !`optionVar -exists sineExclName`) {
- // 0 == no exclusive
- // 1 == exclusive with new name
- // 2 == exclusive using an existing partition
- //
- optionVar -stringValue sineExclName "deformPartition";
- }
- }
-
- //
- // Procedure Name:
- // sineSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // tabIndex - 0 = both tabs, 1 = basic, 2 = advanced
- //
- // Return Value:
- // None.
- //
- global proc sineSetup(string $parent,
- int $forceFactorySettings,
- int $tabIndex)
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
- //
- if ($tabIndex != 2) {
- // min.
- //
- if (`floatSliderGrp -exists sineMin`) {
- floatSliderGrp -edit
- -value `optionVar -query sineMin`
- sineMin;
- }
-
- // max.
- //
- if (`floatSliderGrp -exists sineMax`) {
- floatSliderGrp -edit
- -value `optionVar -query sineMax`
- sineMax;
- }
-
- // amplitude.
- //
- if (`floatSliderGrp -exists sineAmplitude`) {
- floatSliderGrp -edit
- -value `optionVar -query sineAmplitude`
- sineAmplitude;
- }
-
- // wavelength.
- //
- if (`floatSliderGrp -exists sineWavelength`) {
- floatSliderGrp -edit
- -value `optionVar -query sineWavelength`
- sineWavelength;
- }
-
- // dropoff.
- //
- if (`floatSliderGrp -exists sineDropoff`) {
- floatSliderGrp -edit
- -value `optionVar -query sineDropoff`
- sineDropoff;
- }
-
- // offset.
- //
- if (`floatSliderGrp -exists sineOffset`) {
- floatSliderGrp -edit
- -value `optionVar -query sineOffset`
- sineOffset;
- }
- }
-
- if ($tabIndex != 1) {
- // Positioning of the sine deformer in the DG
- //
- string $positioning = `optionVar -query sinePositioning`;
- if (`optionMenuGrp -exists sinePositioningWidget`) {
- if ($positioning == "default") {
- optionMenuGrp -edit -select 1 sinePositioningWidget;
- }
- else if ($positioning == "before") {
- optionMenuGrp -edit -select 2 sinePositioningWidget;
- }
- else if ($positioning == "after") {
- optionMenuGrp -edit -select 3 sinePositioningWidget;
- }
- else if ($positioning == "split") {
- optionMenuGrp -edit -select 4 sinePositioningWidget;
- }
- else if ($positioning == "parallel") {
- optionMenuGrp -edit -select 5 sinePositioningWidget;
- }
- else {
- optionMenuGrp -edit -select 1 sinePositioningWidget;
- }
- }
-
- int $exc=`optionVar -query sineExclusive`;
- if (`checkBoxGrp -exists exclWidget`) {
- checkBoxGrp -e -v1 $exc exclWidget;
- }
- string $exn=`optionVar -query sineExclName`;
- if (`textFieldGrp -exists partitionNameWidget`) {
- textFieldGrp -e -tx $exn -enable $exc partitionNameWidget;
- }
- if (`optionMenuGrp -exists partitionListWidget`) {
- optionMenuGrp -e -enable $exc partitionListWidget;
- }
- }
- }
-
- //
- // Procedure Name:
- // sineCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc sineCallback(string $parent, int $doIt)
- {
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- // Min.
- //
- if (`floatSliderGrp -exists sineMin`) {
- optionVar -floatValue sineMin
- `floatSliderGrp -query -value sineMin`;
- }
-
- // Max.
- //
- if (`floatSliderGrp -exists sineMax`) {
- optionVar -floatValue sineMax
- `floatSliderGrp -query -value sineMax`;
- }
-
- // amplitude.
- //
- if (`floatSliderGrp -exists sineAmplitude`) {
- optionVar -floatValue sineAmplitude
- `floatSliderGrp -query -value sineAmplitude`;
- }
-
- // wavelength.
- //
- if (`floatSliderGrp -exists sineWavelength`) {
- optionVar -floatValue sineWavelength
- `floatSliderGrp -query -value sineWavelength`;
- }
-
- // dropoff.
- //
- if (`floatSliderGrp -exists sineDropoff`) {
- optionVar -floatValue sineDropoff
- `floatSliderGrp -query -value sineDropoff`;
- }
-
- // offset.
- //
- if (`floatSliderGrp -exists sineOffset`) {
- optionVar -floatValue sineOffset
- `floatSliderGrp -query -value sineOffset`;
- }
-
- // Positioning of the sine deformer in the DG
- //
- string $positioning = "default";
- if (`optionMenuGrp -exists sinePositioningWidget`) {
- if (`optionMenuGrp -query -select sinePositioningWidget` == 1) {
- $positioning = "default";
- }
- else if (`optionMenuGrp -query -select sinePositioningWidget` == 2){
- $positioning = "before";
- }
- else if (`optionMenuGrp -query -select sinePositioningWidget` == 3){
- $positioning = "after";
- }
- else if (`optionMenuGrp -query -select sinePositioningWidget` == 4){
- $positioning = "split";
- }
- else if (`optionMenuGrp -query -select sinePositioningWidget` == 5){
- $positioning = "parallel";
- }
- }
- optionVar -stringValue sinePositioning $positioning;
-
- if (`checkBoxGrp -exists exclWidget`) {
- optionVar -intValue sineExclusive `checkBoxGrp -q -v1 exclWidget`;
- }
- if (`optionMenuGrp -exists partitionListWidget`) {
- string $partitionNameVal = `optionMenuGrp -q -v partitionListWidget`;
- if ($partitionNameVal == "Create New Partition") {
- if (`textFieldGrp -exists partitionNameWidget`) {
- $partitionNameVal = `textFieldGrp -q -tx partitionNameWidget`;
- }
- } else {
- // a value of 2 indicates that we use an existing partition
- //
- optionVar -intValue sineExclusive 2;
- }
-
- optionVar -stringValue sineExclName $partitionNameVal;
- }
-
- if ($doIt) {
- performSine 0;
- addToRecentCommandQueue "performSine 0" "Non-Linear";
- }
- }
-
-
- //
- // Procedure Name:
- // createSineTabUI
- //
- // Description:
- // Create the tab UI. The contents of each tab are created only
- // when it is required, ie. if the tab is initially visible or
- // if the tab is selected by the user.
- //
- // Input Arguments:
- // The name of the tab layout.
- //
- // Return Value:
- // None.
- //
- global proc createSineTabUI(string $tabLayout)
- {
- string $tab[] = `tabLayout -query -childArray $tabLayout`;
- int $currentTabIndex = `tabLayout -query -selectTabIndex $tabLayout`;
-
- // Determine if the UI for this tab has been created yet.
- // This is accomplished by querying the number of children
- // in the current tab. If the tab has no children then the UI
- // must be created.
- //
- if (0 == `columnLayout -query -numberOfChildren $tab[$currentTabIndex-1]`) {
-
- setParent $tab[$currentTabIndex-1];
-
- string $label;
- int $index;
-
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- // The current tab has no children. Determine which tab is
- // active and create its UI.
- //
- // RECOMMENDATION: Use the 'Grp' commands where possible because
- // they obey the formatting specified in the default template.
- // This will result in a more consistent look throughout the
- // application.
- //
- if (1 == $currentTabIndex) {
-
- // Create UI for the first tab.
- //
- floatSliderGrp -label "Low Bound" -fieldMinValue -10000.0
- -minValue -10.0 -maxValue 0.0 sineMin;
-
- floatSliderGrp -label "High Bound" -minValue 0.0
- -maxValue 10.0 -fieldMaxValue 10000.0 sineMax;
-
- floatSliderGrp -label "Amplitude" -minValue -5.0 -maxValue 5.0
- -fieldMinValue -10000.0 -fieldMaxValue 10000.0
- sineAmplitude;
-
- floatSliderGrp -label "Wavelength" -minValue -0.1 -maxValue 10.0
- -fieldMinValue -10000.0 -fieldMaxValue 10000.0
- sineWavelength;
-
- floatSliderGrp -label "Dropoff" -minValue -1.0 -maxValue 1.0 -step .1
- sineDropoff;
-
- floatSliderGrp -label "Offset" -minValue -10.0 -maxValue 10.0
- -fieldMinValue -10000.0 -fieldMaxValue 10000.0
- sineOffset;
-
- setParent ..;
- }
- else if (2 == $currentTabIndex) {
-
- // Create UI for the second tab.
- //
- columnLayout -adjustableColumn true;
-
- // Positioning of the sine deformer in the DG
- optionMenuGrp -label "Deformation Order" sinePositioningWidget;
- menuItem -label "Default" sinePosItem1;
- menuItem -label "Before" sinePosItem2;
- menuItem -label "After" sinePosItem3;
- menuItem -label "Split" sinePosItem4;
- menuItem -label "Parallel" sinePosItem5;
-
- separator;
- checkBoxGrp
- -numberOfCheckBoxes 1
- -label ""
- -label1 "Exclusive"
- -v1 0
- -on1 "optionMenuGrp -e -enable 1 partitionListWidget; updatePartitionNameWidget;"
- -offCommand "optionMenuGrp -e -enable 0 partitionListWidget; updatePartitionNameWidget;"
- exclWidget;
-
- // Create an option menu listing the partitions
- //
- optionMenuGrp -l "Partition to Use" -enable `checkBoxGrp -q -v1 exclWidget`
- -cc "updatePartitionNameWidget" partitionListWidget;
-
- string $currentNameOption = "";
- if (`optionVar -exists sineExclName`) {
- $currentNameOption = `optionVar -q sineExclName`;
- }
-
- // add all the partitions to the menu
- //
- int $pp;
- string $partitionArray[];
- $partitionArray = `ls -type partition`;
- int $partitionCount = size($partitionArray);
- menuItem -l "Create New Partition";
- for ($pp = 0; $pp < $partitionCount; $pp++)
- {
- // Do not list the render partition as adding items to
- // it is only going to cause confusion.
- //
- if ($partitionArray[$pp] != "renderPartition" &&
- $partitionArray[$pp] != "characterPartition") {
- menuItem -l $partitionArray[$pp];
- }
- if ($currentNameOption == $partitionArray[$pp]) {
- optionVar -stringValue sineExclName "deformPartition";
- }
- }
-
- textFieldGrp -l "New Partition Name" -enable `checkBoxGrp -q -v1 exclWidget`
- -tx "deformPartition"
- partitionNameWidget;
-
- updatePartitionNameWidget;
- }
-
- // Update the control values to match the options.
- //
- eval (("sineSetup " + $tabLayout + " "+0+" "+$currentTabIndex));
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
- }
- }
-
- //
- // Procedure Name:
- // sineOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- // ********* Change 'sine' in this proc to be the name of your command
- proc sineOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "nonLinear";
-
- // Build the option box actions.
- //
- string $callback = ("sineCallback");
- string $setup = ("sineSetup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- // Note: this option box example delays the creation of the UI
- // until it's required. Therefore this step is moved to the
- // procedure where the UI is actually created.
- //
- //setUITemplate -pushTemplate DefaultTemplate;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
- // This, of course, will vary from option box to option box.
-
- // Demonstrate the delaying of UI creation via tab layouts.
- // Instead of creating all of the option box UI initially, only
- // create that which is initially visible. Wait, until the
- // other tabs are selected to create the remaining UI.
- //
- string $tabLayout = `tabLayout -scrollable 1`;
-
- // Attach an action that will be invoked before a tab is selected.
- //
- tabLayout -edit
- -preSelectCommand ("createSineTabUI " + $tabLayout)
- $tabLayout;
-
- // Create just the immediate children of the tab layout so that
- // the tabs appear.
- //
- columnLayout;
- setParent ..;
- columnLayout;
- setParent ..;
-
- // Set the tab labels.
- //
- tabLayout -edit
- -tabLabelIndex 1 "Basic"
- -tabLabelIndex 2 "Advanced"
- $tabLayout;
-
- // Create the UI for the tab that is initially visible.
- //
- createSineTabUI($tabLayout);
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- // Note: this option box example delays the creation of the UI
- // until it's required. Therefore this step is moved to the
- // procedure where the UI is actually created.
- //
- // See also Step 2.
- //
- //setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label "Create"
- -command ($callback + " " + $tabLayout + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $tabLayout + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $tabLayout + " " + 1 + " " + 0)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("Create Sine Deformer Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "Sine" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- // NOTE: Can not do this here since we do not know what UI is
- // currently visible. This is moved to where the UI is created.
- //
- //eval (($setup + " " + $tabLayout + " " + 0));
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // optionBoxExample1Help
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string sineHelp()
- {
- return
- " Command: sine - creates a sine\n" +
- "Selection: Deformable geometry.";
- }
-
- proc string getCmd()
- {
- string $cmd = "nonLinear -type sine";
-
- $cmd += " -lowBound " + `optionVar -query sineMin`;
- $cmd += " -highBound " + `optionVar -query sineMax`;
- $cmd += " -amplitude " + `optionVar -query sineAmplitude`;
- $cmd += " -wavelength " + `optionVar -query sineWavelength`;
- $cmd += " -dropoff " + `optionVar -query sineDropoff`;
- $cmd += " -offset " + `optionVar -query sineOffset`;
-
- // Build a positioning flag if needed
- //
- string $positioning = `optionVar -query sinePositioning`;
- if ($positioning != "default") {
- $cmd += (" -" + $positioning);
- }
-
- int $exc=`optionVar -query sineExclusive`;
- if ($exc) {
- string $exn=`optionVar -query sineExclName`;
- if ($exn!="") {
- // make sure that we do not clash names with an existing
- // partition when the user requested a new partition, even
- // if the user may have entered a non-unique name
- //
- if ($exc == 1) $exn += "#";
- $cmd += (" -exclusive \"" + $exn+"\"");
- }
- }
-
- return $cmd;
- }
-
-
- //
- // Procedure Name:
- // performSine
- //
- // Description:
- // Perform the sine command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the sine command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
- global proc string performSine(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Retrieve the option settings
- //
- setOptionVars(false);
-
- // Get the command.
- //
- $cmd = getCmd();
-
- // Execute the command with the option settings.
- //
- evalEcho($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- sineOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Retrieve the option settings.
- //
- setOptionVars (false);
-
- // Get the command.
- //
- $cmd = getCmd();
- break;
- }
- return $cmd;
- }
-
-